package com.cskaoyan.service.impl;

import com.cskaoyan.bean.po.MarketGoodsExample;
import com.cskaoyan.bean.po.MarketGoodsProductExample;
import com.cskaoyan.bean.po.MarketOrderExample;
import com.cskaoyan.bean.po.MarketUserExample;
import com.cskaoyan.bean.usersadmin.DashBoardData;
import com.cskaoyan.mapper.MarketGoodsMapper;
import com.cskaoyan.mapper.MarketGoodsProductMapper;
import com.cskaoyan.mapper.MarketOrderMapper;
import com.cskaoyan.mapper.MarketUserMapper;
import com.cskaoyan.service.DashBoardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * ClassName: DashBoardServiceImpl
 * Description:
 * date: 2022/6/7 10:41
 *
 * @author bruce
 * @since JDK 8
 */
@Service
public class DashBoardServiceImpl implements DashBoardService {
    @Autowired
    MarketGoodsMapper marketGoodsMapper;

    @Autowired
    MarketUserMapper marketUserMapper;

    @Autowired
    MarketGoodsProductMapper marketGoodsProductMapper;

    @Autowired
    MarketOrderMapper marketOrderMapper;

    @Override
    public DashBoardData query() {
        MarketGoodsExample goodsExample = new MarketGoodsExample();
        MarketGoodsExample.Criteria criteria = goodsExample.createCriteria();
        criteria.andDeletedEqualTo(false);
        long goodsTotal = marketGoodsMapper.countByExample(goodsExample);

        MarketUserExample userExample = new MarketUserExample();
        MarketUserExample.Criteria criteria1 = userExample.createCriteria();
        criteria1.andDeletedEqualTo(false);
        long userTotal = marketUserMapper.countByExample(userExample);

        MarketGoodsProductExample goodsProductExample = new MarketGoodsProductExample();
        MarketGoodsProductExample.Criteria criteria2 = goodsProductExample.createCriteria();
        criteria2.andDeletedEqualTo(false);
        long productTotal = marketGoodsProductMapper.countByExample(goodsProductExample);

        MarketOrderExample orderExample = new MarketOrderExample();
        MarketOrderExample.Criteria criteria3 = orderExample.createCriteria();
        criteria3.andDeletedEqualTo(false);
        long orderTotal = marketOrderMapper.countByExample(orderExample);

        return new DashBoardData(goodsTotal, userTotal, productTotal, orderTotal);
    }
}
